package de.teamgamma.cansat.groundstation.transmitting;


import org.json.JSONObject;

import de.teamgamma.cansat.groundstation.control.Controller;
import de.teamgamma.cansat.groundstation.database.*;
/**
 * Coordinates all sendings to other stuff
 * @author Alexander Ciupka
 */

public class Transmitter {
	
	private TransmitOptions transmitOptions;
	private DatabaseWriter database;
	private Controller controller;

	/**
	 * constructor
	 */
	
	public Transmitter() {
		transmitOptions = TransmitOptions.getInstance();
		controller = Controller.getInstance();
		database = new DatabaseWriter();
	}
	
	/**
	 * sends the data to all other stations
	 */
	
	public void sendAll(JSONObject data) {
		//checks where the data should be send to
		if (transmitOptions.checkSendToWebsite()) {
			database.sendingData(data);
		}
		if (transmitOptions.checkSendToGroundstation()) {
			controller.update(data);
		}
	}
}
